//
//  CaptureViewController.m
//  OXFAM_iOS
//
//  Created by Karl on 2017/3/24.
//  Copyright © 2017年 i-Craftsmen ltd. All rights reserved.
//

#import "CaptureViewController.h"
#import "CaptureSelectView.h"

@interface CaptureViewController ()
@property (nonatomic,strong) CaptureSelectView *selectView;
@property (nonatomic,strong) UIButton *cameraDirectionBtn;
@property (assign,nonatomic) BOOL isFrontCamera;
@end

@implementation CaptureViewController

- (void)viewDidLoad {
    
    _isFrontCamera = NO;
    
    [super viewDidLoad];
    _selectView = [[CaptureSelectView alloc] init];
    [self.view addSubview:_selectView];
    
    _cameraDirectionBtn = [UIButton new];
    [_cameraDirectionBtn addTarget:self action:@selector(cameraDirectionBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [_cameraDirectionBtn setBackgroundImage:[UIImage imageNamed:@"ar_direction"] forState:UIControlStateNormal];
    [self.view addSubview:_cameraDirectionBtn];
}


- (void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    
    CGFloat scale = 1.0;
    if (isPad) {
        scale = SizeScaleX;
    }else{
        scale = SizeScaleY;
    }
    
    _selectView.centerX = self.view.centerX;
    _selectView.bottom = self.view.bottom - 30 *scale;
    _selectView.width = 200 *scale;
    _selectView.height = 75 *scale;
    
    _cameraDirectionBtn.width = 75*scale;
    _cameraDirectionBtn.height = 75*scale;
    _cameraDirectionBtn.top = 12*scale;
    _cameraDirectionBtn.left = 6*scale;//34.3
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)cameraDirectionBtnAction:(id)sender{
    self.isFrontCamera = !_isFrontCamera;
}

- (void)setIsFrontCamera:(BOOL)isFrontCamera{
    _isFrontCamera = isFrontCamera;
    if (_isFrontCamera) {
        UnitySendMessage("_sceneManager", "ChangeCamera", "front");
    }else{
        UnitySendMessage("_sceneManager", "ChangeCamera", "back");
    }
}

@end
